/*
 * ParsingUtils.h
 *
 *  Created on: Nov 1, 2011
 *      Author: shaohong
 */

#ifndef PARSINGUTILS_H_
#define PARSINGUTILS_H_

#include <string>
#include <list>
#include "RadioChannel.h"

using namespace std;

namespace nmps {

class ParsingUtils {
public:
	ParsingUtils();
	virtual ~ParsingUtils();


	/*
	 * given a html page, parse it and
	 * return extracted the playListURI;
	 *
	 */
	static void extractPlayListURI(char * htmlPage, list<RadioChannel>& radioChannelList);

//	/**
//	 * Given an playListURL such as: "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1926281"
//	 * retrieve the host part of this URL. i.e. return "yp.shoutcast.com"
//	 */
//	static string getHostPartOfURL(char * playlistURI);
//
//	/**
//	 * Given an playListURL such as: "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1926281"
//	 * retrieve the host part of this URL. i.e. return "/sbin/tunein-station.pls?id=1926281";
//	 */
//	static string getPathFromURL(char * playlistURI);

	static string getPlayFileLocationFromHttpResponse(char * httpResponse);

	static void parseRecipientList(char * recipientlistData, list< pair<string, int> > & recipientList);

	/**
	 * Get the number of lines in this sipMessage
	 */
	static int getNumberOfLines(string& sipMessage);

	static string extractMethod(string& currLine);

	static string extractRequestUri(string& currLine);

	static string extractHeaderName(string& currLine);

	static string extractHeaderValue(string& currLine);

	static bool isEmptyLine(string &aLine);

	static void sipGetLine(istream& inputStream, string &lineStr);

	static int extractDTMFSignal(string & contentStr);
};

} /* namespace nmps */
#endif /* PARSINGUTILS_H_ */
